package com.cheng.student.dao;

import com.cheng.student.beans.Teacher;
import com.cheng.student.dao.mappers.TeacherMapper;
import com.cheng.student.utils.SqlSessionGetter;
import org.apache.ibatis.session.SqlSession;

public class TeacherDao
{
    public static void main(String[] args)
    {
        SqlSession sqlSession = SqlSessionGetter.getSqlSession();
        TeacherMapper mapper = sqlSession.getMapper(TeacherMapper.class);
        mapper.insertTeacher("李四","223","223","/");
    }
    public static Teacher selectTeacher(String payrollNumber, String password)
    {
        SqlSession sqlSession = SqlSessionGetter.getSqlSession();

        TeacherMapper mapper = sqlSession.getMapper(TeacherMapper.class);

        Teacher teacher = mapper.selectTeacher(payrollNumber, password);

        sqlSession.close();

        return teacher;
    }

    public static void updatePath(String payrollNumber, String password, String path)
    {
        SqlSession sqlSession = SqlSessionGetter.getSqlSession();

        TeacherMapper mapper = sqlSession.getMapper(TeacherMapper.class);

        mapper.updatePath(payrollNumber,password,path);

        sqlSession.close();

        return;
    }

}
